home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today (BR) Volume 2 #6
/
CDRTV2N6.iso
/
makers
/
search.dir
/
00075_Script_Bsearch script
< prev
next >
Wrap
Text File
|
1996-03-11
|
750b
|
34 lines
on Bsearch str, txt
set txt = the number of cast txt
set start = 1
set end = the number of lines of field txt
set middle = (start + end) / 2
put value(str) into str
put str
repeat while str <> value(item 1 of line middle of field txt)
if str = value(item 1 of line end of field txt) then
return end
end if
if start = middle then
return 0
end if
if str < value(item 1 of line middle of field txt) then
set end = middle
else
set start = middle
end if
set middle = (start + end) / 2
end repeat
if str = value(item 1 of line middle of field txt) then
return middle
else
return 0
end if
end Bsearch